﻿using System;
using Monti.Docking;
using WikiUploader.Controls;

namespace WikiUploader.Classes
{
   /// <summary>
   /// View model for the log control
   /// </summary>
   public class LogViewModel : DockItem
   {
      private string m_Log;
      private readonly LogView m_View;

      /// <summary>
      /// Initializes a new wiki browser.
      /// </summary>
      public LogViewModel ()
      {
         this.Title = "Log";
         this.AllowClose = false;
         this.m_View = new LogView { DataContext = this };
         this.Content = this.m_View;
      }

      /// <summary>
      /// Gets or Sets the log text.
      /// </summary>
      public string Log
      {
         get { return this.m_Log; }
         set
         {
            this.m_Log = value;
            this.RaisePropertyChanged ("Log");
         }
      }

      /// <summary>
      /// Occurs when data is written to the console.
      /// </summary>
      /// <param name="sender">TextWriter.</param>
      /// <param name="e">LineEventArgs</param>
      public void OnWriteLine (object sender, LineEventArgs e)
      {
         this.Log += e.Line;
      }
   }
}
